import java.util.concurrent.ThreadLocalRandom;
import java.util.stream.IntStream;

/**
 * @author cj-ch
 * @date 2018/8/30 下午2:50
 */
public class Tt {


    public static void main(String[] args) throws InterruptedException {
        System.out.println("main start");
        Thread thread = new Thread(() -> {
            IntStream.range(0, 10)
                    .forEach(value -> {
                        int i = ThreadLocalRandom.current().nextInt(10);
                        System.out.println("index=" + value + " i=" + i);
                        if (i <= 3) {
                            Thread.currentThread().interrupt();
                            System.out.println(Thread.currentThread().isInterrupted());
                        }
                        Thread.yield();

                    });
        });
        thread.start();

        thread.join();
        System.out.println("main exit");
    }
}
